<template>
	<div>
		<h3>我的成绩表</h3>
		<hr >
		<table style="width: 100%;line-height: 36px;">
			<tr>
				<td>学生ID</td>
				<td>学生姓名</td>
				<td>班级ID</td>
				<td>班级名称</td>
				<td>课程ID</td>
				<td>课程名称</td>
				<td>成绩</td>
				<td>录入时间</td>
			</tr>
			<tr v-for="m in data.marks">
				<td>{{m.sno}}</td>
				<td>{{m.user.uname}}</td>
				<td>{{m.user.clz.clzno}}</td>
				<td>{{m.user.clz.clzname}}</td>
				<td>{{m.course.cno}}</td>
				<td>{{m.course.cname}}</td>
				<td>{{m.score}}</td>
				<td>{{ dateFmt(m.tpost) }}</td>
			</tr>
		</table>
	</div>
</template>

<script setup>
	import { ref , reactive , onMounted ,computed } from "vue"
	import {$get , $postx} from "../../ajax/index.js"
	import myalert from "../../store/index.js"
	
	const data = reactive({
		marks :[],
	})
	
	const dateFmt =(tpost)=> {
		console.log("时间格式化"); console.log(tpost);
		console.log(typeof tpost);//String
		//转换类型
		let tpo = new Date(tpost);
		let y = tpo.getFullYear();
		let m = tpo.getMonth()+1;
		let d = tpo.getDate();
		
		if(m < 10){m = '0'+m;}
		if(d < 10){d = '0'+d;}
		
		return y+"-"+m+"-"+d;
	}
	
	onMounted( ()=>{
		console.log("学生课程 mounted......");
		$get("/api/fore/stu/findMyMark"
		).then((resp)=>{
			console.log(resp.data.data)
			data.marks = resp.data.data;
		})
	})
	
	computed(()=>{
		
	})
	
</script>

<style>
</style>
